import Vue from 'vue'
import Vuex from 'vuex'

import axios from 'axios'
Vue.use(Vuex)// this.$store

const store = new Vuex.Store({
  state: {
    goodsList: []
  },
  mutations: {
    setGoodsList (state, list) {
      state.goodsList = list
    }
  },
  actions: {
    async asyncSetGoodsList (store) {
      const resp = await axios({ url: 'https://www.escook.cn/api/cart' })
      store.commit('setGoodsList', resp.data.list)
    }
  }
})

export default store
